package org.jfonia.connect5.basics;


/**
 * @author wijnand.schepens@hogent.be
 */
public class BasicValueNode<T> extends BasicNode implements MutableValueNode<T>
{
	protected T value;

	public BasicValueNode(T value)
	{
		this.value = value;
	}

	public T getValue()
	{
		return value;
	}

	public void setValue(T value)
	{
		if ((value != null && !value.equals(this.value)) || (value == null && this.value != null))	// no unnecessary propagation
		{
			this.value = value;
			notifyObservers();
		}
	}

	public void setValue(T value, Observer source)
	{
		if ((value != null && !value.equals(this.value)) || (value == null && this.value != null))	// no unnecessary propagation
		{
			this.value = value;
			notifyObserversExcept(source);
		}
	}

	public Class<?> getType()
	{
		return value.getClass();
	}
	
}
